package com.polaris.live.dialog

import android.content.Context
import androidx.recyclerview.widget.LinearLayoutManager
import com.blankj.utilcode.util.StringUtils
import com.lxj.xpopup.core.CenterPopupView
import com.polaris.live.R
import com.polaris.live.adapter.chatPrice.TodayCallAdapter
import com.polaris.live.common.ext.convertArabicDigitsToNormal
import com.polaris.live.common.ext.setOnSingleClickListener
import com.polaris.live.common.ext.toLevel
import com.polaris.live.databinding.DialogMyLiveDataBinding
import com.polaris.live.resp.back_resp.UserRatingIndicatorVo
import com.polaris.live.translation.R.string
import com.polaris.live.utils.route.RoutePath
import com.polaris.live.utils.route.Router

/**
 * MyLiveDataAdapter
 *
 * @author Created by 半仙 on 2024/1/12/012 11:10
 */
class MyLiveDataDialog(
    context: Context,
    private val mIndicator: UserRatingIndicatorVo,
) : CenterPopupView(context) {

    private lateinit var mBinding: DialogMyLiveDataBinding

    private val mAdapter by lazy { TodayCallAdapter() }

    override fun getImplLayoutId(): Int {
        return R.layout.dialog_my_live_data
    }

    override fun onCreate() {
        super.onCreate()
        mBinding = DialogMyLiveDataBinding.bind(popupImplView)
        mBinding.coinRecycler.layoutManager = LinearLayoutManager(context)
        mBinding.coinRecycler.adapter = mAdapter
        mBinding.tvTodayCallNum.text =
            StringUtils.getString(string.today_call_num, mIndicator.todayCount)
        val level = mIndicator.level.toLong().toLevel.toString()
        mBinding.tvLivingLevel.text =
            "${StringUtils.getString(string.anchor_level)}:L${level.convertArabicDigitsToNormal()}"
        mAdapter.setList(mIndicator.indicators)

        mBinding.ivClose.setOnSingleClickListener {
            dismiss()
        }

        mBinding.goToAnchor.setOnSingleClickListener {
            Router.instance.setPath(RoutePath.MY_ANCHOR_LEVEL_ACTIVITY)
                .navigation(context)
        }
    }
}